package cn.leven.web.response;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
  *重定向 redirect
 *  与转发相反
 *  编写重定向定义方式
 *      1. 设置HTTP状态码为302
 *      2. 设置响应头
 *  不能通过requset域共享数据
  *转发 forword
  *  1.地址栏不变
  *  2.只能访问当前服务器的资源
  *  3.一次请求
*/
@WebServlet("/rdct1")
public class Redirect extends HttpServlet {
    protected void doPost(HttpServletRequest req,HttpServletResponse res) throws IOException {
        res.sendRedirect("https://www.baidu.com");
    }

    protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
        this.doPost(req,res);
    }
}
